<?php

use Illuminate\Support\Facades\Route;

Route::post('/login', 'LoginController@login');
Route::get('/captcha/image', 'CaptchaController@image');
Route::group(['prefix' => 'aliyun'], function () {

    Route::get('/video/play/info', 'AliyunController@getPlayInfo');
    Route::get('/video/list', 'AliyunController@getVideoList');
    Route::get('/image/list', 'AliyunController@getImageList');
});


Route::group(['middleware' => ['auth:administrator']], function () {
    Route::get('/media/images', 'MediaImageController@index');
    Route::get('/media/video/open', 'MediaVideoController@openVideos');
    Route::post('/media/image', 'MediaImageController@upload');
    Route::get('/media/videoLocals', 'MediaVideoLocalController@index');
    Route::post('/media/videoLocal', 'MediaVideoLocalController@upload');
    Route::get('/addons', 'AddonsController@index');

    // 安全退出
    Route::post('/logout', 'LoginController@logout');
});

Route::group(['middleware' => ['auth:administrator', 'backend.permission']], function () {
    Route::get('/user', 'LoginController@user');
    Route::get('/menus', 'LoginController@menus');

    Route::get('/dashboard', 'DashboardController@index');
    Route::get('/dashboard/check', 'DashboardController@check');
    Route::get('/dashboard/system/info', 'DashboardController@systemInfo');

    Route::group(['prefix' => 'media/videos'], function () {
        Route::get('/index', 'MediaVideoController@index');
        Route::post('/create', 'MediaVideoController@store');
        Route::post('/delete/multi', 'MediaVideoController@deleteVideos');
    });



    // 友情链接
    Route::group(['prefix' => 'link'], function () {
        Route::get('/', 'LinkController@index');
        Route::post('/', 'LinkController@store');
        Route::get('/{id}', 'LinkController@edit');
        Route::put('/{id}', 'LinkController@update');
        Route::delete('/{id}', 'LinkController@destroy');
    });
    Route::group(['prefix' => 'menu'], function () {
        Route::get('/', 'CompanyMenuController@tree');
        Route::post('/store', 'CompanyMenuController@store');
        Route::get('/{id}', 'CompanyMenuController@edit');
        Route::put('/{id}', 'CompanyMenuController@update');
        Route::delete('/{id}', 'CompanyMenuController@delete');
    });

    // 幻灯片

    // 广告推广
    Route::group(['prefix' => 'ad_from'], function () {
        Route::get('/', 'AdFromController@index');
        Route::post('/', 'AdFromController@store');
        Route::get('/{id}', 'AdFromController@edit');
        Route::get('/{id}/number', 'AdFromController@number');
        Route::put('/{id}', 'AdFromController@update');
        Route::delete('/{id}', 'AdFromController@destroy');
    });

    // 公告
    Route::group(['prefix' => 'announcement'], function () {
        Route::get('/', 'AnnouncementController@index');
        Route::post('/', 'AnnouncementController@store');
        Route::get('/{id}', 'AnnouncementController@edit');
        Route::put('/{id}', 'AnnouncementController@update');
        Route::delete('/{id}', 'AnnouncementController@destroy');
    });



    // Nav
    Route::group(['prefix' => 'footer_nav'], function () {
        Route::get('/', 'FooterNavController@index');
        Route::get('/create', 'FooterNavController@create');
        Route::post('/', 'FooterNavController@store');
        Route::get('/{id}', 'FooterNavController@edit');
        Route::put('/{id}', 'FooterNavController@update');
        Route::delete('/{id}', 'FooterNavController@destroy');
    });
    Route::group(['prefix' => 'nav'], function () {
        Route::get('/', 'NavController@index');
        Route::get('/create', 'NavController@create');
        Route::post('/', 'NavController@store');
        Route::get('/{id}', 'NavController@edit');
        Route::put('/{id}', 'NavController@update');
        Route::delete('/{id}', 'NavController@destroy');
    });





    // 管理员
    Route::group(['prefix' => 'administrator'], function () {
        Route::put('/password', 'AdministratorController@editPasswordHandle');
        Route::get('/', 'AdministratorController@index');
        Route::get('/create', 'AdministratorController@create');
        Route::post('/', 'AdministratorController@store');
        Route::get('/{id}', 'AdministratorController@edit');
        Route::put('/{id}', 'AdministratorController@update');
        Route::delete('/{id}', 'AdministratorController@destroy');
    });

    // 权限
    Route::group(['prefix' => 'administrator_permission'], function () {
        Route::get('/', 'AdministratorPermissionController@index');
    });

    // 角色
    Route::group(['prefix' => 'administrator_role'], function () {
        Route::get('/', 'AdministratorRoleController@index');
        Route::get('/create', 'AdministratorRoleController@create');
        Route::post('/', 'AdministratorRoleController@store');
        Route::get('/{id}', 'AdministratorRoleController@edit');
        Route::put('/{id}', 'AdministratorRoleController@update');
        Route::delete('/{id}', 'AdministratorRoleController@destroy');
    });



    // 课程
    Route::group(['prefix' => 'course'], function () {
        Route::get('/', 'CourseController@index');

    });
    //图文
    Route::group(['prefix' => 'article'], function () {
        Route::get('/', 'ArticleController@index');


    });


    // 会员
    Route::group(['prefix' => 'member'], function () {
        // 批量导入
        Route::post('/import', 'MemberController@import');

        Route::get('/', 'MemberController@index');
        Route::get('/create', 'MemberController@create');
        Route::get('/{id}', 'MemberController@edit');
        Route::post('/', 'MemberController@store');
        Route::put('/{id}', 'MemberController@update');
        Route::put('/field/multi', 'MemberController@updateFieldMulti');

        // 更新用户标签
        Route::put('/{id}/tags', 'MemberController@tagUpdate');
        // 备注
        Route::get('/{id}/remark', 'MemberController@remark');
        Route::put('/{id}/remark', 'MemberController@updateRemark');

        // 用户详情
        Route::get('/{id}/detail', 'MemberController@detail');
        Route::get('/{id}/detail/userCourses', 'MemberController@userCourses');
        Route::get('/{id}/detail/userVideos', 'MemberController@userVideos');
        Route::get('/{id}/detail/userRoles', 'MemberController@userRoles');
        Route::get('/{id}/detail/userCollect', 'MemberController@userCollect');
        Route::get('/{id}/detail/userHistory', 'MemberController@userHistory');
        Route::get('/{id}/detail/userOrders', 'MemberController@userOrders');
        Route::get('/{id}/detail/userInvite', 'MemberController@userInvite');
        Route::get('/{id}/detail/credit1Records', 'MemberController@credit1Records');



        // 积分变更
        Route::post('/credit1/change', 'MemberController@credit1Change');
        // 发送站内消息
        Route::post('/{id}/message', 'MemberController@sendMessage');
        Route::post('/message/multi', 'MemberController@sendMessageMulti');

        // 用户标签管理
        Route::group(['prefix' => 'tag'], function () {
            Route::get('/index', 'MemberTagController@index');
            Route::get('/create', 'MemberTagController@create');
            Route::post('/create', 'MemberTagController@store');
            Route::get('/{id}', 'MemberTagController@edit');
            Route::put('/{id}', 'MemberTagController@update');
            Route::delete('/{id}', 'MemberTagController@destroy');
        });
    });

    // 网站配置
    Route::group(['prefix' => 'setting'], function () {
        Route::get('/', 'SettingController@index');
        Route::post('/', 'SettingController@saveHandler');
    });

    Route::group(['prefix' => 'company'], function () {
        Route::get('/', 'CompanyController@index');
        Route::post('/subscribe/store', 'CompanyController@createSubscribe');
        Route::delete('/subscribe', 'CompanyController@deleteSubscribe');
        Route::put('/subscribe', 'CompanyController@updateSubscribe');
        Route::get('/role', 'CompanyRoleController@index');
        Route::post('/role/store', 'CompanyRoleController@store');
        Route::get('/role/{id}', 'CompanyRoleController@edit');
        Route::put('/role/{id}', 'CompanyRoleController@update');
        Route::delete('/role/{id}', 'CompanyRoleController@delete');
        Route::put('/role/{id}/title', 'CompanyRoleController@updateTitle');
        Route::delete('/role/{id}/privilege', 'CompanyRoleController@deletePrivilege');
        Route::post('/role/{id}/privilege/store', 'CompanyRoleController@storePrivilege');
        Route::put('privilege/{id}', 'CompanyRoleController@updatePrivilege');
    });

    // 订单
    Route::group(['prefix' => 'order'], function () {
        Route::get('/', 'OrderController@index');
        Route::get('/transfer', 'OrderController@transfer');
        Route::get('/transfer/{id}/handle', 'OrderController@handleTransfer');
        Route::get('/{id}', 'OrderController@detail');
        Route::get('/{id}/finish', 'OrderController@finishOrder');
        Route::post('/{id}/refund', 'OrderController@submitRefund');
        Route::get('/refund/list', 'OrderController@refundOrders');
        Route::delete('/refund/{id}', 'OrderController@deleteRefundOrder');
        Route::post('/withdraw', 'OrderController@withdraw');
        Route::post('/withdrawHandle', 'OrderController@withdrawHandle');
    });

    // 图片上传
    Route::post('/upload/image/tinymce', 'UploadController@tinymceImageUpload');

    // 优惠码
    Route::group(['prefix' => 'promoCode'], function () {
        Route::get('/', 'PromoCodeController@index');
        Route::post('/', 'PromoCodeController@store');
        Route::get('/{id}', 'PromoCodeController@edit');
        Route::put('/{id}', 'PromoCodeController@update');
        Route::post('/delete/multi', 'PromoCodeController@destroy');
        Route::post('/import', 'PromoCodeController@import');
        Route::post('/generator', 'PromoCodeController@generator');
    });


    Route::group(['prefix' => 'statistic'], function () {
        // 每日会员注册数量统计
        Route::get('/userRegister', 'StatisticController@userRegister');
        // 每日订单创建数量统计
        Route::get('/orderCreated', 'StatisticController@orderCreated');
        // 每日订单支付数量统计
        Route::get('/orderPaidCount', 'StatisticController@orderPaidCount');
        // 每日订单已支付总额统计
        Route::get('/orderPaidSum', 'StatisticController@orderPaidSum');
        // 课程每日销售数量统计
        Route::get('/courseSell', 'StatisticController@courseSell');
        // 会员每日销售数量统计
        Route::get('/roleSell', 'StatisticController@roleSell');
        // 每日视频观看时长统计
        Route::get('/videoWatchDuration', 'StatisticController@videoWatchDuration');
        // 每日课程观看时长统计
        Route::get('/courseWatchDuration', 'StatisticController@courseWatchDuration');
    });

    // 微信公众号消息回复
    Route::group(['prefix' => 'mpWechatMessageReply'], function () {
        Route::get('/', 'MpWechatMessageReplyController@index');
        Route::get('/create', 'MpWechatMessageReplyController@create');
        Route::post('/', 'MpWechatMessageReplyController@store');
        Route::get('/{id}', 'MpWechatMessageReplyController@edit');
        Route::put('/{id}', 'MpWechatMessageReplyController@update');
        Route::delete('/{id}', 'MpWechatMessageReplyController@destroy');
    });

    // 微信公众号
    Route::group(['prefix' => 'mpWechat'], function () {
        Route::group(['prefix' => 'menu'], function () {
            Route::get('/', 'MpWechatController@menu');
            Route::put('/', 'MpWechatController@menuUpdate');
            Route::delete('/', 'MpWechatController@menuEmpty');
        });
    });

    // 装修
    Route::group(['prefix' => 'viewBlock'], function () {
        Route::get('/index', 'ViewBlockController@index');
        Route::get('/create', 'ViewBlockController@create');
        Route::post('/create', 'ViewBlockController@store');
        Route::get('/{id}', 'ViewBlockController@edit');
        Route::put('/{id}', 'ViewBlockController@update');
        Route::delete('/{id}', 'ViewBlockController@destroy');
    });



    Route::group(['prefix' => 'strategy'], function () {
        Route::get('/', 'StrategyController@index');
        Route::get('/store', 'StrategyController@store');
        Route::put('/{id}/update', 'StrategyController@update');
        Route::delete('/{id}/delete', 'StrategyController@delete');
    });
    Route::group(['prefix' => 'service'], function () {
        Route::get('/', 'ServiceController@index');
        Route::post('/store', 'ServiceController@store');
        Route::delete('/{id}/delete', 'ServiceController@delete');
        Route::put('/{id}/update', 'ServiceController@update');
    });

    Route::get('/wechat/mini/authorizer', 'WechatOpenController@authorizer');
    Route::get('/wechat/mini/version', 'WechatOpenController@getVersionInfo');
    Route::get('/wechat/mini/template', 'WechatOpenController@miniTemplates');
    Route::post('/wechat/mini/commit', 'WechatOpenController@commit');
    Route::post('/wechat/mini/submit', 'WechatOpenController@submit');
    Route::post('/wechat/mini/release', 'WechatOpenController@release');
    Route::get('/wechat/mini/withdraw', 'WechatOpenController@withdraw');
    Route::get('/wechat/mini/category', 'WechatOpenController@getCategories');
    Route::get('/wechat/mini/qrcode', 'WechatOpenController@getQrCode');
    Route::get('/wechat/mini/qrcode/release', 'WechatOpenController@getReleaseQrCode');
    Route::get('/wechat/mini/latest/audit/status', 'WechatOpenController@getLatestAuditStatus');
    Route::post('/wechat/mini/privacy/setting', 'WechatOpenController@setPrivacy');
    Route::get('/wechat/mini/privacy', 'WechatOpenController@getPrivacy');
    Route::get('/wechat/mini/privacy/info', 'WechatOpenController@getPrivacyInfo');
    Route::post('/wechat/mini/rollback', 'WechatOpenController@rollback');
    Route::post('/wechat/mini/icp/face/send', 'WechatOpenController@sendIcpVerifyTask');
    Route::post('/wechat/mini/icp/face/query', 'WechatOpenController@getIcpFaceStatus');
    Route::post('/wechat/mini/icp/status', 'WechatOpenController@getIcpStatus');
    Route::post('/wechat/mini/domain/set', 'WechatOpenController@setDomain');
    Route::get('/wechat/mini/domain/get', 'WechatOpenController@getEffectivDomain');


});
